package enumAndAnnotation;

/**
 * 枚举练习
 */
public class EnumExercise05 {

    public static void main(String[] args) {
        /*
            匿名内部类的使用
            1)计算机接口具有work方法，功能是运算，有一个手机类Cellphone，定义方法testWork测试计算功能，调用计算机接口的work方法
            2)要求调用Cellphone对象的testWork方法，使用上匿名内部类

            匿名内部类使用
            new ComputerInterface() {
                @Override
                public double work(double n1, double n2) {
                    return n1 + n2;
                }
            }
         */
        Cellphone cellphone = new Cellphone();
        cellphone.testWork(new ComputerInterface() {

            @Override
            public double work(double n1, double n2) {
                return n1 + n2;
            }
        }, 10, 8);
    }
}

interface ComputerInterface {

    public double work(double n1, double n2);

}

class Cellphone {


    public void testWork(ComputerInterface computerInterface, double n1, double n2) {
        double result = computerInterface.work(n1, n2);
        System.out.println("计算后的结果是=" + result);
    }

}